layui.use(['table', 'form', 'jquery', 'common', 'laydate'], function() {
            let table = layui.table;
            let form = layui.form;
            let $ = layui.jquery;
            let common = layui.common;
            let laydate = layui.laydate;

            let cols = [
                [{
                    field: "uid",
                    title: "商户ID",
                    unresize: "true",
                    align: "center"
                }, {
                    field: 'num',
                    title: '工单编号',
                    width: 200,
                    align: 'center',
                }, {
                    field: "types",
                    title: "问题类型",
                    unresize: "true",
                    align: "center"
                }, {
                    field: "biaoti",
                    title: "工单标题",
                    unresize: "true",
                    align: "center",
                }, {
                    field: "edata",
                    title: "提交时间",
                    unresize: "true",
                    align: "center"
                }, {
                    field: "active",
                    title: "回复状态",
                    align: "center",
                    templet: "#active"
                }, {
                    title: '操作',
                    toolbar: '#options',
                    unresize: true,
                    align: 'center',
                    width: 180,
                }]
            ]

            table.render({
                elem: '#news',
                id: 'news',
                url: './ajax1.php?act=WorkgetDataList',
                page: true,
                cols: cols,
                cellMinWidth: 100,
                skin: 'line',
                toolbar: '#toolbar',
                defaultToolbar: [{
                    title: '刷新',
                    layEvent: 'refresh',
                    icon: 'layui-icon-refresh',
                }, 'filter', 'print', 'exports']
            });

            table.on('tool(news)', function(obj) {
                if (obj.event === 'remove') {
                    window.remove(obj);
                } else if (obj.event === 'edit') {
                    window.edit(obj);
                }
            });

            table.on('toolbar(news)', function(obj) {
                if (obj.event === 'refresh') {
                    window.refresh();
                }
            });

            //弹出窗设置 自己设置弹出百分比
            function screen() {
                if (typeof width !== 'number' || width === 0) {
                    width = $(window).width() * 0.8;
                }
                if (typeof height !== 'number' || height === 0) {
                    height = $(window).height() * 0.5;
                }
                return [width + 'px', height + 'px'];
            }

            // 修改数据
            window.edit = function(obj) {
                layer.open({
                    type: 2,
                    maxmin: true,
                    title: '回复管理',
                    shade: 0.1,
                    area: screen(),
                    content: './Work?my=edit&id=' + obj.data['id']
                });
            }

            // 发送修改数据内容
            form.on('submit(editSave)', function(data) {
                $.ajax({
					data: JSON.stringify(data.field),
					url: "./ajax1.php?act=edit_Huifu",
                    contentType: "application/json",
					dataType: 'json',
					type: 'post',
					success: function(res) {
						if (res.code == 200) {
							layer.msg("回复内容成功", {
								icon: 1,
								time: 1000
							}, function() {
								parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭当前页
								parent.layui.table.reload("news");
							});
						} else {
							layer.msg("回复内容失败", {
								icon: 2,
								time: 1000
							});
						}
					}
				})
                return false;
            });

            // 数据删除
            window.remove = function(obj) {
                layer.confirm('确定要删除该工单', {
                    icon: 3,
                    title: '提示'
                }, function(index) {
                    layer.close(index);
                    let loading = layer.load();
                    $.ajax({
                        url: './ajax.php',
                        data: {
                            act:'workremove',
                            id: obj.data['id']
                        },
                        dataType: 'json',
                        type: 'POST',
                        success: function(res) {
                            layer.close(loading);
                            if (res.code == 200) {
                                layer.msg(res.msg, {
                                    icon: 1,
                                    time: 1000
                                }, function() {
                                    obj.del();
                                });
                            } else {
                                layer.msg(res.msg, {
                                    icon: 2,
                                    time: 1000
                                });
                            }
                        }
                    })
                });
            }

            window.refresh = function(param) {
                table.reload('news');
            }

            $('#submitSys').click(function() {
            var pay_work_name = $("#pay_work_name").val();
            var work_zt = $("#work_zt").val();
            $.ajax({
                type: 'POST',
                url: './ajax1.php?act=Set',
                data: {
                    pay_work_name:pay_work_name,
                    work_zt:work_zt
                },
                dataType: 'json',
                success: function(data) {
                    if (data.code == 1) {
                        layer.alert('设置保存成功！', {
                            icon: 1,
                            closeBtn: false
                        }, function() {
                            window.location.reload()
                        });
                    } else {
                        layer.alert(data.msg, {
                            icon: 2
                        })
                    }
                },
                error: function(data) {
                    layer.msg('服务器错误');
                    return false;
                }
            });
            return false;
        });

        })